package com.ydd.network.mina;

import android.app.Service;
import android.content.Context;
import android.support.v4.app.NotificationCompat;

import java.util.List;

/**
 * Created by tao on 17-3-23.
 * 构建者模式
 */

public class ConnectionConfig {
    private Context context;
    private String ip;
    private int port;
    private int readBUfferSize;
    private long connectionTimeout;

    public Context getContext() {
        return context;
    }

    public void setContext(Context context) {
        this.context = context;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public int getReadBUfferSize() {
        return readBUfferSize;
    }

    public void setReadBUfferSize(int readBUfferSize) {
        this.readBUfferSize = readBUfferSize;
    }

    public long getConnectionTimeout() {
        return connectionTimeout;
    }

    public void setConnectionTimeout(long connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
    }

    public static class Builder {
        private Context context;
        private String ip = "192.168.43.8";
        private int port = 9124;
        private int readBUfferSize = 10240;
        private long connectionTimeout = 10000;

        public Builder(Context context) {
            this.context = context;
        }

        public Builder setIp(String ip) {
            this.ip = ip;

            return this;
        }

        public Builder setPort(int port) {
            this.port = port;

            return this;
        }

        public Builder setReadBUfferSize(int readBUfferSize) {
            this.readBUfferSize = readBUfferSize;

            return this;
        }

        public Builder setConnectionTimeout(long connectionTimeout) {
            this.connectionTimeout = connectionTimeout;

            return this;
        }

        private void applyConfig(ConnectionConfig config) {
            config.context = this.context;
            config.ip = this.ip;
            config.port = this.port;
            config.readBUfferSize = this.readBUfferSize;
            config.connectionTimeout = this.connectionTimeout;
        }

        public ConnectionConfig builder() {
            ConnectionConfig config = new ConnectionConfig();
            applyConfig(config);

            return config;
        }
    }
}
